import request from '@/utils/request'

// 查询生产退料单列表
export function listReturn(query) {
  return request({
    url: '/production/return/list',
    method: 'get',
    params: query
  })
}

// 查询生产退料单详细
export function getReturn(returnId) {
  return request({
    url: '/production/return/' + returnId,
    method: 'get'
  })
}

// 新增生产退料单
export function addReturn(data) {
  return request({
    url: '/production/return',
    method: 'post',
    data: data
  })
}

// 修改生产退料单
export function updateReturn(data) {
  return request({
    url: '/production/return',
    method: 'put',
    data: data
  })
}

// 删除生产退料单
export function delReturn(returnIds) {
  return request({
    url: '/production/return/' + returnIds,
    method: 'delete'
  })
}

// 校验退料单编号
export function checkReturnCodeUnique(params) {
  return request({
    url: '/production/return/checkReturnCodeUnique',
    method: 'get',
    params: params
  })
}

// 根据工单ID查询退料单列表
export function listByWorkOrderId(workOrderId) {
  return request({
    url: '/production/return/listByWorkOrderId/' + workOrderId,
    method: 'get'
  })
}

// 根据领料单ID查询退料单列表
export function listByPickingId(pickingId) {
  return request({
    url: '/production/return/listByPickingId/' + pickingId,
    method: 'get'
  })
}

// 审核生产退料单
export function auditReturn(returnId, status) {
  return request({
    url: '/production/return/audit/' + returnId + '/' + status,
    method: 'put'
  })
}

// 执行生产退料单
export function executeReturn(returnId) {
  return request({
    url: '/production/return/execute/' + returnId,
    method: 'put'
  })
}